package com.first.agent.web.controller;

import com.alibaba.fastjson.JSONObject;
import com.first.agent.common.R;
import com.first.agent.service.FinancialManagementService;
import com.first.agent.service.impl.FinancialManagementServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
/*
财务管理
 */
public class FinancialManagementServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String user_name = request.getParameter("user_name");
        String fil_type_id = request.getParameter("fil_type_id");
        String financial_funds = request.getParameter("financial_funds");
        String remark = request.getParameter("remark");
        FinancialManagementService financialManagementService = new FinancialManagementServiceImpl();
        R r = financialManagementService.FinancialManagement(user_name, Integer.parseInt(fil_type_id), Double.parseDouble(financial_funds), remark);
        response.setContentType("application/json;charset=utf-8");
        PrintWriter pw=response.getWriter();
        pw.write(JSONObject.toJSONString(r));
        pw.flush();
        pw.close();
    }
}
